/**
 * Created by admin on 2017/10/26.
 */
$(document).ready(function () {
    $("form").submit(function () {
        return false;
    });
   // var actFlg = "";
    var VAL = {
        NORMAL: "0000000",
        EVT_USER: $("#userId").text(),
        T_FBPBISOPE: 'FBPBISOPE',
        T_FBPBISTOL: 'FBPBISTOL',
        T_FBPBISPTH: 'FBPBISPTH',
        T_FIPINQBOX: 'FIPINQBOX',
        T_FDPAPLYWO: "FDPAPLYWO",
        T_FBPMDLDEF: "FBPMDLDEF",
        T_FPPWHSOPE: "FPPWHSOPE",
        T_FBPBISDAT: "FBPBISDAT",
        T_FPPMOVEOUT: 'FPPMOVEOUT',
        T_FBPSWHPTH: "FBPSWHPTH",
        T_FIPINQSHT: "FIPINQSHT",
        DISABLED_ATTR: {
            'disabled': true
        },
        ENABLED_ATTR: {
            'disabled': false
        }
    };
    var domObj = {

        buttons: {
            $query_btn: $("#query_btn"),
            $save_btn: $("#save_btn"),
            $clean_btn: $("#clean_btn"),
        },
     /*   $factorySite: $("#factorySite"),*/
        $bayId: $("#bayId"),
       /* $factoryId: $("#factoryId"),*/
        $woCateSel: $("#woCateSel"),
        $woIdFk: $("#woIdFk"),
        $opeIdFk: $("#opeIdFk"),
        $toolIdFk: $("#toolIdFk"),
        $prdSeqId: $("#prdSeqId"),


        $lotId: $("#lotId"),
        $productId: $("#productId"),
        $radioOK: $("#radioOK"),
        $radioNG: $("#radioNG"),
        $defectCode: $("#defectCode"),
        $gradeGRP: $("#gradeGRP"),
        $prdGrade: $("#prdGrade"),
        $reWork: $("#reWork"),
        $prdNote: $("#prdNote"),
        $mdlId: $("#mdlId"),
        $pathId: $("#pathId"),
        $nxOpe: $("#nxOpeSel"),


        grids: {
            $prodListDiv: $("#prodListDiv"),
            $prodListGrd: $("#prodListGrd"),
            $prodListPg: $("#prodListPg"),
        },
        dialogs: {
            $DFCodeDialog: $("#DFCodeDialog"),
            $defectListDiv: $("#defectListDiv"),
            $defectListGrd: $("#defectListGrd"),
            $defectListPg: $("#defectListPg"),
            $defectCode_sureBtn: $("#defectCode_sureBtn"),

        },
    }

    function initInner() {
        domObj.grids.$prodListGrd
            .jqGrid({
                url: "",
                datatype: "local",
                mtype: "POST",
                height: 400,
                width: $("#prodListDiv").width() * 0.99,
                autowidth: false,
                shrinkToFit: true,
                resizable: true,
                loadonce: true,
                viewrecords: true,
                rownumbers: true,
                rowNum: 20,
                emptyrecords: true,
                colModel: [
                    {
                        name: 'wo_id_fk',
                        index: 'wo_id_fk',
                        label: '工单号',
                        width: 130
                    }, {
                        name: 'prd_seq_id',
                        index: 'prd_seq_id',
                        label: '玻璃代码',
                        width: 100
                    }, {
                        name: 'prd_stat',
                        index: 'prd_stat',
                        label: '玻璃状态',
                        width: 100
                    }, {
                        name: 'mdl_id_fk',
                        index: 'mdl_id_fk',
                        label: '产品代码',
                        width: 150
                    }, {
                        name: 'ope_id_fk',
                        index: 'ope_id_fk',
                        label: '站点代码',
                        width: 100
                    }, {
                        name: 'lot_id',
                        index: 'lot_id',
                        label: '批次号',
                        width: 100
                    }, {
                        name: 'so_id_fk',
                        index: 'so_id',
                        label: '客户订单号',
                        width: 150
                    }],
                pager: "#prodListPg",
                onSelectRow: function (rowId) {
                }
            });
        domObj.dialogs.$defectListGrd
            .jqGrid({
                url: "",
                datatype: "local",
                mtype: "POST",
                height: 400,
                width: 800,//($("#defectListDiv").width()) * 0.99,
                autowidth: false,
                shrinkToFit: true,
                resizable: true,
                loadonce: true,
                viewrecords: true,
                rownumbers: true,
                rowNum: 20,
                emptyrecords: true,
                colModel: [
                    {
                        name: 'data_id',
                        index: 'data_id',
                        label: '缺陷代码',
                        width: 60
                    }, {
                        name: 'data_ext',
                        index: 'data_ext',
                        label: '缺陷代码描述',
                        width: 130
                    }],
            });
    }

    var initSelectFnc = {
      /*  initFactSite: function () {
            comAddValueByDataCateFnc("#factorySite", "SITE", "data_ext", "data_desc", true);
        },*/
      /*  initFactory: function () {
            var fact_site = domObj.$factorySite.find("option:selected").val();
            var inObj = {
                trx_id: VAL.T_FBPBISDAT,
                action_flg: "Q",
                iary: [{
                    data_cate: 'FBID',
                    data_item: fact_site
                }]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                SelectDom.addSelectArr(domObj.$factoryId, outObj.oary, "data_ext", "data_desc", "", true);
            }
        },*/
       /* initBayArea: function () {
            var factoryId = domObj.$factoryId.find("option:selected").val();
            var inObj = {
                trx_id: VAL.T_FBPBISDAT,
                action_flg: "Q",
                iary: [{
                    data_cate: 'AREA',
                    data_item: factoryId
                }]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                SelectDom.addSelectArr(domObj.$bayId, outObj.oary, "data_ext", "data_desc", "", true);
            }
        },*/
        initWoType: function () {
            comAddValueByDataCateFnc("#woCateSel", "WOCT", "data_ext", "data_desc", true);
        },
        iniWoIdSel: function () {
            var wo_cate = domObj.$woCateSel.find("option:selected").val();
            var inObj = {
                trx_id: VAL.T_FDPAPLYWO,
                action_flg: "Q",
                iary: [{
                    wo_cate: wo_cate
                }]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                SelectDom.addSelectArr(domObj.$woIdFk, outObj.oary, "wo_id", "wo_id", "", true);
            }
        },
        iniOpeIdSel: function () {
            var inObj = {
                trx_id: VAL.T_FBPBISOPE,
                action_flg: "Q",
                iary: [{}]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                SelectDom.addSelectArr(domObj.$opeIdFk, outObj.oary, "ope_id", "ope_id", "", true);
            }
        },
        iniToolIdSel: function () {
            /*var fact_site = domObj.$factorySite.find("option:selected").val();
            var factoryId = domObj.$factoryId.find("option:selected").val();*/
            var bay_area = domObj.$bayId.find("option:selected").val();
            var ope_id_fk = domObj.$opeIdFk.find("option:selected").val();
            var inObj = {
                trx_id: VAL.T_FBPBISTOL,
                action_flg: "M",
                iary: [{
                   /* fab_site_fk: fact_site,
                    fab_id_fk: factoryId,*/
                    bay_id: bay_area,
                    ope_id_fk: ope_id_fk
                }]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                SelectDom.addSelectArr(domObj.$toolIdFk, outObj.oary, "tool_id", "tool_id", "", true);
            }
        },
        iniGdGRPSel: function () {
            // var id = $('#prodListGrd').jqGrid('getGridParam', 'selrow');
             var okng = "";
            // rowData = domObj.grids.$prodListGrd.jqGrid("getRowData", id);
            // if (rowData.prd_seq_id != null) {
            //     prdSeqId = rowData.prd_seq_id;
            // } else {
            //     prdSeqId = domObj.$prdSeqId.val().trim();
            // }
            // if (!prdSeqId) {
            //     showErrorDialog("", "玻璃代码不能为空");
            //     return false;
            // }
            var mdlId = domObj.$mdlId.val().trim();
            // if (!mdlId) {
            //     showErrorDialog("", "玻璃产品代码为空");
            //     return false;
            // }
            if ($("#radioOK").attr("checked") == "checked") {
                okng = "OK";
            } else {
                okng = "NG";
            }
            var inObj = {
                trx_id: VAL.T_FBPMDLDEF,
                action_flg: "M",
                iary: [{
                    mdl_id: mdlId,
                    okng: okng
                }]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                SelectDom.addSelectArr(domObj.$gradeGRP, outObj.oary, "gd_grd", "gd_grd", "", true);
            }
        },
        iniPrdGRPSel: function (gd_grp) {
            var okng = "";
            var mdlId = domObj.$mdlId.val().trim();
            // if (!mdlId) {
            //     showErrorDialog("", "玻璃产品代码为空");
            //     return false;
            // }
            if ($("#radioOK").attr("checked") == "checked") {
                okng = "OK";
            } else {
                okng = "NG";
            }
            var iary = {
                mdl_id: mdlId,
                okng: okng
            }
            if (gd_grp) {
                iary.gd_grd = gd_grp;
            }
            var inObj = {
                trx_id: VAL.T_FBPMDLDEF,
                action_flg: "N",
                iary: [iary]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                SelectDom.addSelectArr(domObj.$prdGrade, outObj.oary, "prd_grade", "prd_grade_desc", "", true);
            }
        },
        iniReWorkSel: function () {
            var opeIdFk = domObj.$opeIdFk.val().trim();
            if (!opeIdFk) {
                showErrorDialog("", "站点代码不能为空");
                return false;
            }
            var inObj = {
                trx_id: VAL.T_FBPSWHPTH,
                action_flg: 'Q',
                iary: [{
                    fr_ope_no_fk: opeIdFk,
                    swh_typ: 'R'
                }]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                SelectDom.addSelectArr(domObj.$reWork, outObj.oary, "swh_path_id_fk", "swh_path_id_fk", "", true);
            }

        },
        iniNxtOpeSel: function () {
            // var opeIdFk = domObj.$opeIdFk.val().trim();
            // if (!opeIdFk) {
            //     //showErrorDialog("", "站点代码不能为空");
            //     return false;
            // }
            // var okng = "OK";
            // if ($("#radioOK").attr("checked") == "checked") {
            //     okng = "OK";
            // } else {
            //     okng = "NG";
            // }
            // var rwkPathId = domObj.$pathId.val().trim();
            // var inObj = {
            //     trx_id: VAL.T_FBPBISDAT,
            //     action_flg: "Q",
            //     iary: [{
            //         data_cate: 'FRTO',
            //         data_ext: rwkPathId,
            //         data_item: okng,
            //         ext_1: opeIdFk
            //     }]
            // };
            // var outObj = comTrxSubSendPostJson(inObj);
            // if (outObj.rtn_code == VAL.NORMAL) {
            //     SelectDom.addSelectArr(domObj.$nxOpe, outObj.oary, "ext_2", "ext_2", "", true);
            // }
            var path_id = domObj.$pathId.val().trim();
            var path_ver = "00000";
            if(!path_id){
                showErrorDialog("", "请先查询玻璃信息");
                return false;
            }
            var iary ={
                path_id : path_id,
                path_ver: path_ver
            };
            var inObj={
                trx_id      : VAL.T_FBPBISPTH ,
                action_flg  : "Q"        ,
                iaryA        : [iary]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                SelectDom.addSelectArr(domObj.$nxOpe, outObj.oaryB, "cr_ope_no", "cr_ope_id_fk", "", true);
            }
        }
    }
    var toolFunc = {
        query_func: function () {
            var inObj, outObj, iary;
            var bayId, woIdFk, opeIdfk, toolIdFk, prdSeqId;

            prdSeqId = domObj.$prdSeqId.val().trim();
            // iary = {
            //     fab_site_fk: factSite,
            //     fab_id_fk  : factoryId,
            //     bay_id     : bayId ,
            //     wo_id_fk   : woIdFk,
            //     ope_id_fk  : opeIdfk,
            //     tool_id_fk : toolIdFk
            // }
            inObj = {
                trx_id: VAL.T_FIPINQSHT,
                evt_usr: VAL.EVT_USER,
                action_flg: 'Q',
                prd_seq_id: prdSeqId
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                // if(actFlg=="MAN"&&outObj.path_cate=="RWK"){
                //     showErrorDialog("", "此玻璃在重工途程,请到重工站点过账");
                //     return false;
                // }
                if(outObj.path_cate=="MAN"){
                    showErrorDialog("", "此玻璃在主途程,请到主站点过账");
                    return false;
                } else if(outObj.prd_stat=="WAIT"){
                   /* showErrorDialog("", "此玻璃不在制程中");
                    return false;*/
                    //直接入账下一站
                    //先查站点
                    var inObj2 = {
                        trx_id : VAL.T_FBPBISTOL,
                        action_flg : "M",
                        iary : [{
                           /* fab_site_fk : outObj.fab_site_id_fk, //工厂坐落地方
                            fab_id_fk   : outObj.fab_id_fk, //厂别*/
                            /* bay_id      : bay_area,*/
                            ope_id_fk   : outObj.ope_id_fk
                        }]
                    };
                    var outObj2 = comTrxSubSendPostJson(inObj2);
                    if (outObj2.rtn_code == VAL.NORMAL) {
                        if(outObj2.oary.length > 0){
                            var toolId = outObj2.oary[0].tool_id;
                            var iary = {
                               /* fab_site_fk: outObj.fab_site_fk,
                                fab_id_fk: outObj.fab_id_fk,
                                bay_id     : bay_id,*/
                                prd_seq_id: prdSeqId,
                                wo_id_fk: outObj.wo_id_fk,
                                ope_id_fk: outObj.ope_id_fk,
                                tool_id_fk: toolId
                            }
                            var inObj3 = {
                                trx_id: VAL.T_FPPMOVEIN,
                                evt_usr: VAL.EVT_USER,
                                action_flg: 'A',
                                iary: [iary]
                            };
                            var outObj3 = comTrxSubSendPostJson(inObj3);
                            if (outObj3.rtn_code == VAL.NORMAL) {
                            }
                        }
                    }
                }
                setGridInfo(outObj, "#prodListGrd");
               /* domObj.$factorySite.val(outObj.fab_site_id_fk);
                domObj.$factoryId.val(outObj.fab_id_fk);*/
                domObj.$woIdFk.val(outObj.wo_id_fk);
                domObj.$woCateSel.val(outObj.wo_cate);
                domObj.$opeIdFk.val(outObj.cr_ope_id_fk);
                domObj.$toolIdFk.val(outObj.cr_tool_id_fk);
                domObj.$mdlId.val(outObj.mdl_id_fk);
                domObj.$pathId.val(outObj.cr_path_id_fk);
                var prd_grade = outObj.prd_grade;
                //初始化重工路线
                initSelectFnc.iniNxtOpeSel();
                if(outObj.okng_flg=="OK"){
                    $("#radioOK").attr("checked",true);
                    toolFunc.radioOkFnc(prd_grade);
                }else{
                    $("#radioNG").attr("checked",true);
                    toolFunc.radioNgFnc(prd_grade);
                }
                // initSelectFnc.iniGdGRPSel();
                // initSelectFnc.iniPrdGRPSel("");
                domObj.$gradeGRP.val(outObj.grade_group).trigger("change");
                domObj.$prdGrade.val(outObj.prd_grade).trigger("change");
                if(outObj.ope_cate !="M"){
                    // $("#middleRightDiv").hide();
                    domObj.$gradeGRP.attr(VAL.DISABLED_ATTR);
                    domObj.$prdGrade.attr(VAL.DISABLED_ATTR);
                }else{
                    // $("#middleRightDiv").show();
                    domObj.$gradeGRP.attr(VAL.ENABLED_ATTR);
                    domObj.$prdGrade.attr(VAL.ENABLED_ATTR);
                }
            }

        },
        save_func: function () {
            var inObj, outObj, iary, rowData,prdStat;
            var prdSeqId;
            var id = $('#prodListGrd').jqGrid('getGridParam', 'selrow');
            rowData = domObj.grids.$prodListGrd.jqGrid("getRowData", id);
            if (rowData.prd_seq_id != null) {
                prdSeqId = rowData.prd_seq_id;
            } else {
                prdSeqId = domObj.$prdSeqId.val().trim();
            }
            if (!prdSeqId) {
                showErrorDialog("", "玻璃代码不能为空");
                return false;
            }
            if (domObj.$radioOK.prop('checked')) {
                 prdStat = 'OK'
            } else {
                 prdStat = 'NG'
            }
            var defectCode = domObj.$defectCode.val().trim();
            var prdGrade = domObj.$prdGrade.val();
            var reWork = domObj.$reWork.val();
            var prdNote = domObj.$prdNote.val().trim();
            if (!prdGrade) {
                showErrorDialog("", "产品等级不能为空");
                return false;
            }
            if(prdStat=="NG"&&!defectCode){
                showErrorDialog("", "缺陷代码不能为空");
                return false;
            }
            var nx_rwk_ope = domObj.$nxOpe.val();
            var nx_rwk_ope_id = domObj.$nxOpe.find("option:selected").text();
            iary = {
                prd_seq_id: prdSeqId,
                prd_stat: prdStat,
                defect_code: defectCode,
                prd_grade: prdGrade,
                prdNote: prdNote,
                reWork: reWork,
                reOpe: nx_rwk_ope,
                reOpe_id :nx_rwk_ope_id
            }
            inObj = {
                trx_id: VAL.T_FPPMOVEOUT,
                evt_usr: VAL.EVT_USER,
                action_flg: 'O',
                iary: [iary]
            };
            outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                toolFunc.clean_func();
                //setGridInfo(outObj.oary, "#prodListGrd");
                showSuccessDialog("出账成功");
            }
        },
        clean_func: function () {
            $("input").val("");
            $("select").empty();
            $("select").val("").trigger("change");
            domObj.grids.$prodListGrd.jqGrid("clearGridData");
            domObj.dialogs.$defectListGrd.jqGrid("clearGridData");
            initializationFunc();
        },
        changeOkFnc:function () {
            $("#reWork").attr(VAL.DISABLED_ATTR);
            domObj.$defectCode.attr(VAL.ENABLED_ATTR);
            domObj.$prdNote.attr(VAL.ENABLED_ATTR);
        },
        changeNgFnc: function(){
            domObj.$defectCode.attr(VAL.ENABLED_ATTR);
            domObj.$prdNote.attr(VAL.ENABLED_ATTR);
            $("#reWork").attr(VAL.ENABLED_ATTR);
        },
        radioOkFnc: function (prd_grade) {
            $("#reWork").attr(VAL.DISABLED_ATTR);
            domObj.$defectCode.attr(VAL.DISABLED_ATTR);
            domObj.$prdNote.attr(VAL.DISABLED_ATTR);
            initSelectFnc.iniGdGRPSel();
            initSelectFnc.iniPrdGRPSel("");
            if(prd_grade){
                SelectDom.setSelect(domObj.$prdGrade,prd_grade,prd_grade);
                var inObj = {
                    trx_id : VAL.T_FBPMDLDEF,
                    action_flg : 'Q',
                    iary: [{
                        prd_grade: prd_grade
                    }]
                };
                var outObj = comTrxSubSendPostJson(inObj);
                if(outObj.rtn_code === VAL.NORMAL){
                    var gd_grp = outObj.oary[0].gd_grp;
                    SelectDom.setSelect(domObj.$gradeGRP,gd_grp,gd_grp)
                }
            }
        },
        radioNgFnc: function (prd_grade) {
            initSelectFnc.iniGdGRPSel();
            initSelectFnc.iniPrdGRPSel("");
            // if(actFlg=="MAN"){
            //     initSelectFnc.iniReWorkSel();
            // }else{
                initSelectFnc.iniNxtOpeSel();
            //}
            domObj.$defectCode.attr(VAL.ENABLED_ATTR);
            domObj.$prdNote.attr(VAL.ENABLED_ATTR);
            $("#reWork").attr(VAL.ENABLED_ATTR);
            if(prd_grade){
                SelectDom.setSelect(domObj.$prdGrade,prd_grade,prd_grade);
                var inObj = {
                    trx_id : VAL.T_FBPMDLDEF,
                    action_flg : 'Q',
                    iary: [{
                        prd_grade: prd_grade
                    }]
                };
                var outObj = comTrxSubSendPostJson(inObj);
                if(outObj.rtn_code === VAL.NORMAL){
                    var gd_grp = outObj.oary[0].gd_grp;
                    SelectDom.setSelect(domObj.$gradeGRP,gd_grp,gd_grp)
                }
            }
        },
        defectCodeDialogFnc: function () {
            domObj.dialogs.$defectListGrd
                .jqGrid("clearGridData");
            // 缺陷代码对话框的模型
            domObj.dialogs.$DFCodeDialog.modal({
                backdrop: true,
                keyboard: false,
                show: false
            });
            domObj.dialogs.$DFCodeDialog.modal("show");
            var inObj = {
                trx_id: VAL.T_FBPBISDAT,
                action_flg: "Q",
                iary: [{
                    data_cate: 'DFCT',
                    ext_1: domObj.$opeIdFk.val().trim()
                }]
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code == VAL.NORMAL) {
                setGridInfo(outObj.oary, "#defectListGrd");
            }
        },
        dialogSureFnc: function () {
            var id = $('#defectListGrd').jqGrid('getGridParam', 'selrow');
            var rowData = domObj.dialogs.$defectListGrd.jqGrid("getRowData", id);
            if (rowData.length == 0) {
                showErrorDialog("", "缺陷代码不能为空");
                return false;
            }
            domObj.$defectCode.val(rowData.data_id);
            domObj.dialogs.$DFCodeDialog.modal("hide");
        }
    }
    var initializationFunc = function () {
        initInner();
        // if (GetQueryString("pageCate") == "MAN") {
        //     actFlg = "MAN";
        //     $("#nxOpeDiv").hide();
        //     $("title").text("1300:主站点出账");
        // } else if (GetQueryString("pageCate") == "RWK") {
          //  actFlg = "RWK";
            $("#rwkRouteDiv").hide();
            $("title").text("1A00:重工站点出账");
       // }
        //initSelectFnc.initFactSite();
        //initSelectFnc.initFactory();
        //initSelectFnc.initBayArea();
        //initSelectFnc.iniWoIdSel();
        //initSelectFnc.initWoType();
        //initSelectFnc.iniOpeIdSel();
        //initSelectFnc.iniToolIdSel();

        // domObj.$woCateSel.change(function () {
        //     initSelectFnc.iniWoIdSel();
        // });
        // domObj.$factorySite.change(function () {
        //     initSelectFnc.initFactory();
        //     initSelectFnc.iniToolIdSel();
        // });
        // domObj.$factoryId.change(function () {
        //     initSelectFnc.initBayArea();
        //     initSelectFnc.iniToolIdSel();
        // });
        // domObj.$bayId.change(function () {
        //     initSelectFnc.iniToolIdSel();
        // });
        // domObj.$opeIdFk.change(function () {
        //     initSelectFnc.iniToolIdSel();
        // });
        domObj.$gradeGRP.change(function () {
            var gd_grp = domObj.$gradeGRP.val();
            if (!gd_grp) {
               // showErrorDialog("", "请选择缺陷种类");
                return false;
            }
            initSelectFnc.iniPrdGRPSel(gd_grp);
        });
    };
    initializationFunc();
    domObj.buttons.$query_btn.bind('click', toolFunc.query_func);
    domObj.buttons.$save_btn.bind('click', toolFunc.save_func);
    domObj.buttons.$clean_btn.bind('click', toolFunc.clean_func);

    domObj.$prdSeqId.keydown(function (event) {
        if (event.keyCode == 13) {
            toolFunc.query_func();
        }
    });

    domObj.$radioNG.bind('click', toolFunc.changeNgFnc);
    domObj.$radioOK.bind('click', toolFunc.changeOkFnc);
    domObj.dialogs.$defectCode_sureBtn.bind('click', toolFunc.dialogSureFnc);
    domObj.$defectCode.focus(function () {
        domObj.$defectCode.val("");
        toolFunc.defectCodeDialogFnc();
    });


    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null)return unescape(r[2]);
        return null;
    }


    //表格自适应
    function resizeFnc() {
        var offsetBottom, grdDivWidth;
        grdDivWidth = $("#divTop").width();
        offsetBottom = $(window).height() - $("#prodListDiv").offset().top;

        $("#prodListDiv").width(grdDivWidth * 0.98);
        $("#prodListDiv").height(offsetBottom * 0.99);
        $("#prodListDiv").setGridWidth(grdDivWidth * 0.97);
        $("#prodListGrd").setGridHeight(offsetBottom * 0.95 - 51);
    };

    resizeFnc();
    $(window).resize(function () {
        resizeFnc();
    });
});
